#include <jni.h>
#include <stdlib.h>
#include <string.h>
#include <android/log.h>
#include "../cpp/ed-aes.h"

#define LOG_I(...) __android_log_print(ANDROID_LOG_INFO, "NATIVE-CRYPTO", __VA_ARGS__)

JNIEXPORT jint JNICALL
Java_com_example_guard_1corelibrary_Utils_extractFile(JNIEnv *env, jclass type,
                                                      jstring enCryptoFile_, jstring destFile_) {
    const char *enCryptoFile = (*env)->GetStringUTFChars(env, enCryptoFile_, 0);
    const char *destFile = (*env)->GetStringUTFChars(env, destFile_, 0);
    LOG_I("-------------native decrypt\n %s\n %s\n", enCryptoFile, destFile);
    int result = decryptFile(destFile, enCryptoFile, DEFAULT_PW, NULL);
    LOG_I("-------------native decrypt finish resultCode:%d \n", result);
    (*env)->ReleaseStringUTFChars(env, enCryptoFile_, enCryptoFile);
    (*env)->ReleaseStringUTFChars(env, destFile_, destFile);
    return result;
}
